package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResPicture;
import com.hmkj.entity.ErspResRequest;

public class ErspResRequestDao extends JActiveTable {
	public ErspResRequestDao() {
		this.setDBTableName("ersp_res_request");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("req_sn", "req_sn", ActiveField.ftString, 36));
		AddField(new JActiveField("org_id", "org_id", ActiveField.ftString, 36));
		AddField(new JActiveField("user_id", "user_id", ActiveField.ftString, 36));
		AddField(new JActiveField("req_content", "req_content", ActiveField.ftString, 500));
		AddField(new JActiveField("resp_result", "resp_result", ActiveField.ftString, 2));
		AddField(new JActiveField("req_start", "req_start", ActiveField.ftString, 20));
		AddField(new JActiveField("req_end", "req_end", ActiveField.ftString, 20));
		AddField(new JActiveField("req_status", "req_status", ActiveField.ftString, 11));
		AddField(new JActiveField("req_signin", "req_signin", ActiveField.ftString, 20));
		AddField(new JActiveField("create_time", "create_time", ActiveField.ftString, 20));

		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspResRequest vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("req_sn", vo.getReq_sn());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_id", vo.getUser_id());
		setFieldValue("req_content", vo.getReq_content());
		setFieldValue("resp_result", vo.getResp_result());
		setFieldValue("req_start", vo.getReq_start());
		setFieldValue("req_end", vo.getReq_end());
		setFieldValue("req_status", vo.getReq_status());
		setFieldValue("req_signin", vo.getReq_signin());
		setFieldValue("create_time", vo.getCreate_time());
		
		
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspResRequest vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("req_sn", vo.getReq_sn());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_id", vo.getUser_id());
		setFieldValue("req_content", vo.getReq_content());
		setFieldValue("resp_result", vo.getResp_result());
		setFieldValue("req_start", vo.getReq_start());
		setFieldValue("req_end", vo.getReq_end());
		setFieldValue("req_status", vo.getReq_status());
		setFieldValue("req_signin", vo.getReq_signin());
		setFieldValue("create_time", vo.getCreate_time());
		return this.getSQL();
	}
}
